<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Smarty {link_rewrite} function plugin
 *
 * Type:     function<br>
 * Name:     link_rewrite<br>
 * Date:     Jan 14, 2008<br>
 * Purpose:  rewrite url links<br>
 * @author   leo tan <tanjnr at gmail dot com>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_link_rewrite($params, &$smarty)
{
	global $sysconf,$urlconf;
	$url = '';

	foreach($params as $_key => $_val) 
	{
		if ($sysconf['urlrewrite'])
		{
			$url .= $_val.'_';
		}
		else
		{
			$url .= $_key.'='.$_val.'&';
		}
	}

	$url = substr($url, 0, strlen($url)-1);

	if ($sysconf['urlrewrite'])
	{
		$url .= $sysconf['htmlextent'];
	}
	else
	{
		$url = $urlconf['default'].'?'.$url;
	}

    return $urlconf['domains'].$url;
}

/* vim: set expandtab: */

?>
